package com.taojin.shoppinginterest.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.taojin.shoppinginterest.R;
import com.taojin.shoppinginterest.bean.info;
import com.taojin.shoppinginterest.utils.BitmapHelper;

import java.util.List;

public class ListFragmentAdapter extends AppAdapter<info> {
    private BitmapUtils bitmapUtils;

    public ListFragmentAdapter(List<info> list, Context context) {
        super(list, context);
        bitmapUtils = BitmapHelper.getInstance().getBitmapUtils(context, R.mipmap.icon, R.mipmap.icon);
    }
    @Override
    public View createItemView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_listfragmentadapter, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        bitmapUtils.display(viewHolder.list_item_iamge, list.get(position).getImg_url());
        return convertView;
    }

    private static class ViewHolder {
        @ViewInject(R.id.list_item_iamge)
        private ImageView list_item_iamge;
        public ViewHolder(View convertView) {
            ViewUtils.inject(this, convertView);
        }
    }

}
